package edu.parq.uaa.dict;

import java.sql.ResultSet;

import edu.parq.uaa.db.DB;

public class PopulateDictionary {

	
	public static void main(String [] args)throws Exception{
		long st=System.currentTimeMillis();
		long st1=System.currentTimeMillis();
		DB db=new DB();
		long d=0;
		ResultSet rset=db.getData();
		long messages=0;
		while (rset.next()){
			String str=rset.getString(1);
			System.out.println(++messages);
			String words[]=str.split(" ");
			for (int i=0;i<words.length;i++){
				++d;
				try{
				db.addDataToDictionary(words[i]);
				}catch(Exception e){
					System.out.println("Exception in " + words[i]);
					e.printStackTrace();
				}
				
				if (d%1000==0){
					System.out.println("Time Taken till now (" + d + ") " + ((System.currentTimeMillis() - st)/60000) + " minutes"); 
					System.out.println("Time Taken per 1000 sentences " + ((System.currentTimeMillis() - st1)/60000) + " minutes");
					st1=System.currentTimeMillis();
				}
					
			}
		}
		
		System.out.println(d);
		
		db.close();
	}
	
}
